/////////////////////////////////////////////////////////////////////////////
// Name:        MainFrame.cpp
// Purpose:     
// Author:      Andrew (cod) Bulavinov
// Modified by: 
// Created:     06/01/2009 18:20:41
// RCS-ID:      
// Copyright:   
// Licence:     
/////////////////////////////////////////////////////////////////////////////

// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"

#ifdef __BORLANDC__
#pragma hdrstop
#endif

#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif

////@begin includes
////@end includes

#include "MainFrame.h"

////@begin XPM images
////@end XPM images

#include "SettingsDlg.h"
#include "AnimeCataloguerApp.h"

/*!
 * MainFrame type definition
 */

IMPLEMENT_CLASS( MainFrame, wxFrame )


/*!
 * MainFrame event table definition
 */

BEGIN_EVENT_TABLE( MainFrame, wxFrame )

////@begin MainFrame event table entries
    EVT_MENU( wxID_EXIT, MainFrame::OnEXITClick )

    EVT_MENU( ID_MENU_SETTINGS, MainFrame::OnMENUSETTINGSClick )

    EVT_MENU( ID_MENU_UPDATE, MainFrame::OnMENUUPDATEClick )

    EVT_MENU( ID_MENU_SYNC, MainFrame::OnMENUSYNCClick )

    EVT_MENU( ID_MENU_ABOUT, MainFrame::OnMENUABOUTClick )

////@end MainFrame event table entries

END_EVENT_TABLE()


/*!
 * MainFrame constructors
 */

MainFrame::MainFrame()
{
    Init();
}

MainFrame::MainFrame( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
{
    Init();
    Create( parent, id, caption, pos, size, style );
}


/*!
 * MainFrame creator
 */

bool MainFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
{
////@begin MainFrame creation
    wxFrame::Create( parent, id, caption, pos, size, style );

    CreateControls();
    Centre();
////@end MainFrame creation
    return true;
}


/*!
 * MainFrame destructor
 */

MainFrame::~MainFrame()
{
////@begin MainFrame destruction
////@end MainFrame destruction
}


/*!
 * Member initialisation
 */

void MainFrame::Init()
{
////@begin MainFrame member initialisation
////@end MainFrame member initialisation
}


/*!
 * Control creation for MainFrame
 */

void MainFrame::CreateControls()
{    
////@begin MainFrame content construction
    MainFrame* itemFrame1 = this;

    wxMenuBar* menuBar = new wxMenuBar;
    wxMenu* itemMenu3 = new wxMenu;
    itemMenu3->Append(ID_MENU_OPEN_FILE, _("Open"), _T(""), wxITEM_NORMAL);
    itemMenu3->Append(ID_MENU_SAVE_FILE, _("Save"), _T(""), wxITEM_NORMAL);
    itemMenu3->AppendSeparator();
    itemMenu3->Append(wxID_EXIT, _("E&xit"), _T(""), wxITEM_NORMAL);
    menuBar->Append(itemMenu3, _("&File"));
    wxMenu* itemMenu8 = new wxMenu;
    itemMenu8->Append(ID_MENU_SETTINGS, _("&Settings"), _T(""), wxITEM_NORMAL);
    itemMenu8->Append(ID_MENU_UPDATE, _("&Update"), _T(""), wxITEM_NORMAL);
    itemMenu8->Append(ID_MENU_SYNC, _("S&ync"), _T(""), wxITEM_NORMAL);
    menuBar->Append(itemMenu8, _("&Tools"));
    wxMenu* itemMenu12 = new wxMenu;
    itemMenu12->Append(ID_MENU_ABOUT, _("&About"), _T(""), wxITEM_NORMAL);
    menuBar->Append(itemMenu12, _("&Help"));
    itemFrame1->SetMenuBar(menuBar);

    wxBoxSizer* itemBoxSizer14 = new wxBoxSizer(wxVERTICAL);
    itemFrame1->SetSizer(itemBoxSizer14);

    wxListCtrl* itemListCtrl15 = new wxListCtrl( itemFrame1, ID_EDIT_LIST, wxDefaultPosition, wxSize(100, 100), wxLC_REPORT );
    itemBoxSizer14->Add(itemListCtrl15, 1, wxGROW, 5);

    wxStatusBar* itemStatusBar16 = new wxStatusBar( itemFrame1, ID_STATUSBAR, wxST_SIZEGRIP|wxNO_BORDER );
    itemStatusBar16->SetFieldsCount(2);
    itemBoxSizer14->Add(itemStatusBar16, 0, wxALIGN_CENTER_HORIZONTAL, 5);

////@end MainFrame content construction
}


/*!
 * Should we show tooltips?
 */

bool MainFrame::ShowToolTips()
{
    return true;
}

/*!
 * Get bitmap resources
 */

wxBitmap MainFrame::GetBitmapResource( const wxString& name )
{
    // Bitmap retrieval
////@begin MainFrame bitmap retrieval
    wxUnusedVar(name);
    return wxNullBitmap;
////@end MainFrame bitmap retrieval
}

/*!
 * Get icon resources
 */

wxIcon MainFrame::GetIconResource( const wxString& name )
{
    // Icon retrieval
////@begin MainFrame icon retrieval
    wxUnusedVar(name);
    return wxNullIcon;
////@end MainFrame icon retrieval
}


/*!
 * wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU_SETTINGS
 */

void MainFrame::OnMENUSETTINGSClick( wxCommandEvent& event )
{
    SettingsDlg dlg(this);
    if (dlg.ShowModal() == wxID_OK) {
    }
}


/*!
 * wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU_UPDATE
 */

void MainFrame::OnMENUUPDATEClick( wxCommandEvent& event )
{
    wxGetApp().GetSources().Update();
}


/*!
 * wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU_SYNC
 */

void MainFrame::OnMENUSYNCClick( wxCommandEvent& event )
{
////@begin wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU_SYNC in MainFrame.
    // Before editing this code, remove the block markers.
    event.Skip();
////@end wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU_SYNC in MainFrame. 
}


/*!
 * wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU_ABOUT
 */

void MainFrame::OnMENUABOUTClick( wxCommandEvent& event )
{
////@begin wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU_ABOUT in MainFrame.
    // Before editing this code, remove the block markers.
    event.Skip();
////@end wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU_ABOUT in MainFrame. 
}


/*!
 * wxEVT_COMMAND_MENU_SELECTED event handler for wxID_EXIT
 */

void MainFrame::OnEXITClick( wxCommandEvent& event )
{
    //TODO: Check for saving
    wxGetApp().Exit();
}

